{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "603008e1-c54e-4d02-bfae-b6d90c358c37",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入整数n（n>=0）： 4\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4 != 24\n"
     ]
    }
   ],
   "source": [
    "def fact(n): #声明函数，返回值\n",
    "    if n==0:\n",
    "        f=1\n",
    "    else:\n",
    "        f=n*fact(n-1)\n",
    "    return(f)\n",
    "n=int(input(\"请输入整数n（n>=0）：\"))\n",
    "print(n,\"!=\",fact(n))      #调用函数\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8763e93f-b902-422b-9fa1-83260872bc93",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
